
//conversion_from_and_into_test

use std::convert::From;

#[derive(Debug)]
pub struct Number {
    value: i32,
}

impl From<i32> for Number {
    fn from(item: i32) -> Self {
        Number { value: item }
    }
}

pub fn conversion_from_and_into_test() {
    let num = Number::from(30);
    println!("My number is {:?}", num);
    //
    let int = 5;
    println!("Try removing the type declaration。 // 实现了from 那么i32类型就能直接用into方法实现转换。类似c#的扩展方法");
    let num: Number = int.into();
    println!("My number is {:?}", num);
}
